package day7;

import java.util.*;

public class TestMap {
    public static void main(String[] args) {
        Map<String, Integer> map1 = new HashMap<>();
        //不允许key value为null
        //默认11  new对象初始化为11  0.75   2n+1
        //线程安全(方法添加了同步锁)    效率比较低
        Map<String, Integer> map2 = new Hashtable<>();
        map1.put(null, null);
        map1.put("java", null);
        map1.put(null, 99);  //覆盖了 第13行

        //迭代器遍历
        Iterator<Map.Entry<String, Integer>> it = map1.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry<String, Integer> e = it.next();
            String key = e.getKey();
            Integer value = e.getValue();
            System.out.println(key + "==" + value);
        }

        //map2.put(null, null);
        //map2.put("java",null);
        //map2.put(null,99);
        //System.out.println(map2);
    }
}
